@model  BarManager.UI.Web.Models.OrdenViewModel

<table class="table table-striped table-hover table-condensed">
    <tr>
        <th style="text-align:center;">Item</th>
        <th style="text-align:center;">Cantidad</th>
        <th style="text-align:center;">Precio</th>
        <th style="text-align:center;">Cant. Pagada</th>
        <th style="text-align:center;">Cant. Por Pagar</th>
        <th style="text-align:center;">Cant. Regalos</th>
        <th style="text-align:center;">Pagado</th>
        <th style="text-align:center;">Por Pagar</th>
        <th style="text-align:center;">Pagar</th>
        <th style="text-align:center;">Regalar</th>
        <th style="text-align:center;">Cantidad</th>
    </tr>
    @if (Model.Entity != null && Model.Entity.Detalle != null)
    {
        foreach (var item in Model.Entity.Detalle)
        {
            <tr>
                <td>
                    @if (item is BarManager.Core.Entity.OrdenDetalleProducto)
                    {
                        <div data-toggle="tooltip" title="@(((BarManager.Core.Entity.OrdenDetalleProducto)item).Producto.Nombre)">
                            @(string.IsNullOrEmpty(((BarManager.Core.Entity.OrdenDetalleProducto)item).Producto.Nombre) ? "" :
                                (((BarManager.Core.Entity.OrdenDetalleProducto)item).Producto.Nombre.Length < 40 ? ((BarManager.Core.Entity.OrdenDetalleProducto)item).Producto.Nombre.ToString() :
                                ((BarManager.Core.Entity.OrdenDetalleProducto)item).Producto.Nombre.ToString().Substring(0, 40) + "..."))
                        </div>
                    }
                    else
                    {
                        <div data-toggle="tooltip" title="@(((BarManager.Core.Entity.OrdenDetallePromocion)item).Promocion.Descripcion)">
                            @(string.IsNullOrEmpty(((BarManager.Core.Entity.OrdenDetallePromocion)item).Promocion.Descripcion) ? "" :
                                (((BarManager.Core.Entity.OrdenDetallePromocion)item).Promocion.Descripcion.Length < 40 ? ((BarManager.Core.Entity.OrdenDetallePromocion)item).Promocion.Descripcion.ToString() :
                                ((BarManager.Core.Entity.OrdenDetallePromocion)item).Promocion.Descripcion.ToString().Substring(0, 40) + "..."))
                        </div>
                    }
                </td>
                <td style="text-align:center;">@item.Cantidad</td>
                <td style="text-align:center;">@item.Precio.ToString("c")</td>
                <td style="text-align:center;">@item.CantidadPagada</td>
                <td style="text-align:center;">@item.CantidadPorPagar</td>
                <td style="text-align:center;">@item.CantidadRegalada</td>
                <td style="text-align:center;"><span class="badge badge-success">@item.SubTotalPagado.ToString("c")</span></td>
                <td style="text-align:center;"><span class="badge badge-warning">@item.SubTotalPorPagar.ToString("c")</span></td>

                <td style="text-align:center;">

                    @Html.Raw(Ajax.ActionLink("[Add]", "PartialPayAdd", "Orden",
                              new { guid = @item.Guid },
                              new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Add]", "<i class=\"icon-chevron-up\" data-toggle=\"tooltip\" title=\"Agregar\"></i>")) |

                    @Html.Raw(Ajax.ActionLink("[Remove]", "PartialPayRemove", "Orden",
                              new { guid = @item.Guid },
                           new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Remove]", "<i class=\"icon-chevron-down\" data-toggle=\"tooltip\" title=\"Descontar\"></i>"))

                </td>

                <td style="text-align:center;">

                    @Html.Raw(Ajax.ActionLink("[Add]", "GiftAdd", "Orden",
                              new { guid = @item.Guid },
                              new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Add]", "<i class=\"icon-chevron-up\" data-toggle=\"tooltip\" title=\"Agregar\"></i>")) |

                    @Html.Raw(Ajax.ActionLink("[Remove]", "GiftRemove", "Orden",
                              new { guid = @item.Guid },
                           new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Remove]", "<i class=\"icon-chevron-down\" data-toggle=\"tooltip\" title=\"Descontar\"></i>"))

                </td>

                <td style="text-align:center;">

                    @Html.Raw(Ajax.ActionLink("[Add]", "ItemAdd", "Orden",
                              new { guid = @item.Guid },
                              new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Add]", "<i class=\"icon-chevron-up\" data-toggle=\"tooltip\" title=\"Agregar\"></i>")) |

                    @Html.Raw(Ajax.ActionLink("[Remove]", "ItemRemove", "Orden",
                              new { guid = @item.Guid },
                           new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                      .ToHtmlString().Replace("[Remove]", "<i class=\"icon-chevron-down\" data-toggle=\"tooltip\" title=\"Descontar\"></i>")) |

                    @Html.Raw(Ajax.ActionLink("[Delete]", "DetalleRemove", "Orden",
                              new { guid = @item.Guid },
                           new AjaxOptions { UpdateTargetId = "ordenDetalle", HttpMethod = "Post", OnSuccess = "AddTooltip" })
                         .ToHtmlString().Replace("[Delete]", "<i class=\"icon-remove\" data-toggle=\"tooltip\" title=\"Eliminar\"></i>"))

                </td>
            </tr>
        }
    }

    @if (Model.Entity != null && Model.Entity.Detalle != null && Model.Entity.Detalle.Count > 0)
    {
        <tfoot>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td style="text-align:center;"><strong>Total</strong></td>
                <td style="text-align:center;">
                    <strong>@(Model.Entity.TotalPorPagar.Value.ToString("c"))</strong>
                </td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </tfoot>
        @Html.Hidden("countItems", Model.Entity.Detalle.Count)
    }
</table>